
import { createRouter, createWebHistory } from 'vue-router';

const routes = [
  {
    path: '/panda',
    name: 'panda',
    component: () => import('../components/Panda.vue'),
    meta: { title: '熊猫' }
  },
  {
    path: '/loong',
    name: 'loong',
    component: () => import('../components/Loong.vue'),
    meta: { title: '龙' }
  },
  {
    path: '/fox',
    name: 'fox',
    component: () => import('../components/Fox.vue'),
    meta: { title: '狐狸' }
  },
  {
    path: '/lion',
    name: 'lion',
    component: () => import('../components/Lion.vue'),
    meta: { title: '狮子' }
  },
  {
    path: '/tiger',
    name: 'tiger',
    component: () => import('../components/Tiger.vue'),
    meta: { title: '老虎' }
  },
  {
    path: '/eagle',
    name: 'eagle',
    component: () => import('../components/Eagle.vue'),
    meta: { title: '鹰' }
  },
  {
    path: '/whale',
    name: 'whale',
    component: () => import('../components/Whale.vue'),
    meta: { title: '鲸' }
  },
  {
    path: '/bear',
    name: 'bear',
    component: () => import('../components/Bear.vue'),
    meta: { title: '熊' }
  },
  {
    path: '/leopard',
    name: 'leopard',
    component: () => import('../components/Leopard.vue'),
    meta: { title: '豹' }
  },
  {
    path: '/cat',
    name: 'cat',
    component: () => import('../components/Cat.vue'),
    meta: { title: '猫' }
  },
  {
    path: '/setup',
    name: 'setup',
    component: () => import('../views/Father.vue'),
    meta: { title: '父子组件' }
  },
  {
    path: '/monkey',
    name: 'monkey',
    component: () => import('../views/Monkey.vue'),
    meta: { title: '猴' }
  },
  {
    path: '/cart',
    name: 'cart',
    component: () => import('../views/CartView.vue'),
    meta: { title: '购物车' }
  },
];

const routerOptions = {
  history: createWebHistory(),
  routes
}

const router = createRouter( routerOptions );

router.afterEach( to => {
  document.title = to.meta.title ;
})

export default router;